<?php
   class Content extends MY_Controller{
	   public function __construct(){
		   parent::__construct();
		   $this->load->helper("url");
		   $this->load->model("mcon");		   
	   }
	   public function listall(){
	   	   $segment_1 = (int)$this->uri->segment(2);
		   $id = array_pop(explode('-', $segment_1));
		   $segment_2 = (int)$this->uri->segment(3);
		   $start = array_pop(explode('-', $segment_2));
		   $action = array("trang");	
		   $getVar = $this->uri->uri_to_assoc(1, $action);
		   $config['base_url'] = base_url()."kien-thuc/".$getVar['kien-thuc']."";
		   $config['total_rows'] = $this->mcon->count_all($id);
		   $config['per_page'] = 7;
		   $config['uri_segment'] = 3;
		   $config['next_link'] = "Next";
		   $config['prev_link'] = "Prev";
		   $this->load->library("pagination",$config);
		   $data['menu'] = $this->menu();
		   $data['menuintro'] = $this->menu_intro();
		   $data['menustreng'] = $this->menu_streng();
		   $data['menukt'] = $this->menu_kt();
		   $data['support'] = $this->support();	
		   $data['listcon'] = $this->mcon->getcon($id,$config['per_page'],$start);
		   $ok = $this->mcon->get_name($id);
		   if($ok == NULL){
		   		redirect(base_url());
				exit();
		   }
		   $data['title'] = $ok["cago_name"];
		   $this->load->view("content/layout",$data);
	   }
	   public function liststreng(){
	   	   $segment_1 = (int)$this->uri->segment(2);
		   $id = array_pop(explode('-', $segment_1));
		   $segment_2 = (int)$this->uri->segment(3);
		   $start = array_pop(explode('-', $segment_2));
		   $action = array("trang");	
		   $getVar = $this->uri->uri_to_assoc(1, $action);
		   $config['base_url'] = base_url()."the-manh/".$getVar['the-manh']."";
		   $config['total_rows'] = $this->mcon->count_all($id);
		   $config['per_page'] = 6;
		   $config['uri_segment'] = 3;
		   $config['next_link'] = "Next";
		   $config['prev_link'] = "Prev";
		   $this->load->library("pagination",$config);
		   $data['menu'] = $this->menu();
		   $data['menuintro'] = $this->menu_intro();
		   $data['menustreng'] = $this->menu_streng();
		   $data['menukt'] = $this->menu_kt();
		   $data['support'] = $this->support();			   
		   $data['listcon'] = $this->mcon->getcon($id,$config['per_page'],$start);
		   $ok = $this->mcon->get_name($id);
		   if($ok == NULL){
		   		redirect(base_url());
				exit();
		   }
		   $data['title'] = $ok["cago_name"];
		   $this->load->view("content/streng/layout",$data);
	   }
	   public function read(){
		   $id = (int)$this->uri->segment(4);
		   $data['menu'] = $this->menu();
		   $data['menuintro'] = $this->menu_intro();
		   $data['menustreng'] = $this->menu_streng();
		   $data['menukt'] = $this->menu_kt();
		   $data['support'] = $this->support();			   
		   //$data['name'] = $oki['m_name'];
		   //$ok = $this->mcon->getcate($id1);
		   $data['read'] = $this->mcon->detail($id);
		   if($data['read'] == NULL){
		   		redirect(base_url());
				exit();
		   }
		   $oki = $this->mcon->get_name($data['read']['cago_id']);
		   $data['cate_name'] = $oki['cago_name'];
		   $data['liqu'] = $this->mcon->listcon($data['read']['cago_id'],$id);
		   $data['title'] = $data['read']['post_title'];
		   $this->load->view("content/detail/layout",$data);
	   }
   }